package server;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class LagouServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) throws Exception {
        String content = "<h1>LagouServlet get</h1>";
        try {
            TimeUnit.MILLISECONDS.sleep(5000);
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) +content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) throws Exception {
        String content = "<h1>LagouServlet post</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) +content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() {
        System.out.println("==>> initting ...");
    }

    @Override
    public void destroy() {
        System.out.println("====>>> destorying ...");
    }
}
